import request from "@/utils/request.ts";
import type { SysResponse} from "@/api/commonType.ts";
import type {FamilyCard, FamilyForm} from "@/api/family/type.ts";


export enum API {
  GET_ALL_FAMILY = "/api/family/getAll",
  ADD_FAMILY = "/api/family/save",
  DELETE_FAMILY = "/api/family/delete",
}

/**
 * 获取所有家庭
 */
export function getAllFamily() {
  return request.get<string, SysResponse<FamilyCard[]>>(API.GET_ALL_FAMILY)
}


/**
 * 添加家庭
 * @param data
 */
export function saveFamily(data: FamilyForm) {
  return request.post<string, SysResponse<null>>(API.ADD_FAMILY, data
  )
}

/**
 * 删除家庭
 * @param familyId
 */
export function deleteFamilyById(familyId: number) {
  return request.delete<string, SysResponse<null>>(API.DELETE_FAMILY + `/${familyId}`)
}

